/*    */ package com.zimbra.cs.servlet;
/*    */ 
/*    */ import com.zimbra.common.service.ServiceException;
/*    */ import com.zimbra.common.util.Log;
/*    */ import com.zimbra.common.util.LogFactory;
/*    */ import com.zimbra.common.util.ZimbraLog;
/*    */ import com.zimbra.cs.account.Provisioning;
/*    */ import com.zimbra.cs.account.Server;
/*    */ import com.zimbra.cs.server.ServerConfig;
/*    */ import java.net.InetAddress;
/*    */ import java.net.UnknownHostException;
/*    */ import java.util.List;
/*    */ import javax.servlet.FilterConfig;
/*    */ import javax.servlet.ServletException;
/*    */ import javax.servlet.ServletRequest;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class DoSFilter
/*    */   extends org.eclipse.jetty.servlets.DoSFilter
/*    */ {
/*    */   public void init(FilterConfig filterConfig)
/*    */     throws ServletException
/*    */   {
/* 40 */     LogFactory.init();
/* 41 */     super.init(filterConfig);
/*    */     try {
/* 43 */       List<Server> servers = Provisioning.getInstance().getAllServers("mailbox");
/* 44 */       for (Server server : servers) {
/*    */         try {
/* 46 */           InetAddress[] addresses = InetAddress.getAllByName(server.getServiceHostname());
/* 47 */           for (InetAddress address : addresses) {
/* 48 */             addWhitelistAddress(address.getHostAddress());
/*    */           }
/*    */         } catch (UnknownHostException e) {
/* 51 */           ZimbraLog.misc.warn("Invalid hostname: " + server.getServiceHostname(), e);
/*    */         }
/*    */       }
/* 54 */       String[] addrs = ServerConfig.getAddrListCsv(Provisioning.getInstance().getLocalServer().getHttpThrottleSafeIPs());
/* 55 */       for (String addr : addrs) {
/* 56 */         addWhitelistAddress(addr);
/*    */       }
/*    */     } catch (ServiceException e) {
/* 59 */       ZimbraLog.misc.warn("Unable to get throttle safe IPs", e);
/*    */     }
/*    */     
/* 62 */     addWhitelistAddress("127.0.0.1");
/* 63 */     addWhitelistAddress("::1");
/* 64 */     addWhitelistAddress("0:0:0:0:0:0:0:1");
/* 65 */     ZimbraLog.misc.info("DoSFilter: Configured whitelist IPs = " + getWhitelist());
/*    */   }
/*    */   
/*    */   public boolean addWhitelistAddress(String address)
/*    */   {
/* 70 */     ZimbraLog.misc.debug("added whitelist address [%s]", new Object[] { address });
/* 71 */     return super.addWhitelistAddress(address);
/*    */   }
/*    */   
/*    */   protected String extractUserId(ServletRequest request)
/*    */   {
/* 76 */     return ZimbraQoSFilter.extractUserId(request);
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/servlet/DoSFilter.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */